﻿/*
创建人：朱楠
日期：2024-07-17
描述：工步排产参数维护js
*/
var page = {
  mainUrl: getRootPath() + "/Ashx/APSHandler/RBStepParameterMaintPageHandler.ashx", //本页面后台路径
  commonUrl: getRootPath() + "/Ashx/CommonHandler.ashx", //通用方法后台路径
  //初始化页面
  init: function () {
    page.bind();
    page.initData(); //初始化页面数据
    page.addEditCell();
  },
  workflowid: '',
  editIndex: null, //easyUI单元格编辑
  // 给easyuigrid新增editcell方法
  addEditCell: function () {
    $.extend($.fn.datagrid.methods, {
      editCell: function (jq, param) {
        return jq.each(function () {
          var opts = $(this).datagrid('options');
          var fields = $(this).datagrid('getColumnFields', true).concat($(this).datagrid('getColumnFields'));
          for (var i = 0; i < fields.length; i++) {
            var col = $(this).datagrid('getColumnOption', fields[i]);
            col.editor1 = col.editor;
            if (fields[i] != param.field) {
              col.editor = null;
            }
          }
          $(this).datagrid('beginEdit', param.index);
          for (var i = 0; i < fields.length; i++) {
            var col = $(this).datagrid('getColumnOption', fields[i]);
            col.editor = col.editor1;
          }
        });
      }
    });
  },
  endEditing: function (gridId) {
    if (page.editIndex == undefined) { return true }
    if ($('#' + gridId).datagrid('validateRow', page.editIndex)) {
      $('#' + gridId).datagrid('endEdit', page.editIndex);
      page.editIndex = undefined;
      return true;
    } else {
      return false;
    }
  },
  //页面事件绑定
  bind: function () {
    var wname = decodeURIComponent(getParam("wname"));
    var wid = getParam("wid");
    var pname = decodeURIComponent(getParam("pname"));
    var pid = getParam("pid")

    // 工序信息表格
    $("#tbSpec").datagrid({
      columns: [[
        { field: 'ck', title: '选择', checkbox: true },
        { field: 'workflowstepid', title: 'workflowstepid', hidden: true },
        { field: 'workflowstepname', title: 'workflowstepname', hidden: true },
        { field: 'specno', title: '工序号', width: 80 },
        { field: 'opdesc', title: '工序名称', width: 100 },
        { field: 'workcentername', title: '工区', width: 100 },
        { field: 'teamname', title: '班组', width: 100 },
        // { field: 'WORKFLOWSTEPNAME', title: '转工周期', width: 200 },
        { field: 'childworkflow', title: '通用子工艺', width: 200 },
        { field: 'factoryname', title: '工艺所属分厂', width: 100 },
        { field: 'fullname', title: '工艺员', width: 80 },
        { field: 'workflowtype', title: '工艺类型', width: 100 },
        { field: 'process_no', title: '工艺规程编号', width: 160 },
        { field: 'ly2sequence', title: '工艺规程版次', width: 100 },
        { field: 'defaultproduct', title: '工艺关联件号', width: 260 },
        { field: 'lastchangedate', title: '上次变更日期', width: 180 },
      ]],
      onCheck: function (rowIndex, rowData) {
        page.getStepInfoData(rowData.workflowstepid);
      }
    });

    // 工步信息表格
    $("#tbSteps").datagrid({
      columns: [[
        { field: 'ck', title: '选择', checkbox: true },
        { field: 'stepinfoid', title: 'stepinfoid', hidden: true },
        { field: 'stepno', title: '工步号', width: 80 },
        { field: 'stepdesc', title: '工步名称', width: 80 },
        { field: 'steptype', title: '工步类型', width: 100 },
        { field: 'workcentername', title: '工区', width: 100 },
        { field: 'teamname', title: '班组', width: 100 },
        { field: 'preparecycle', title: '准备时间', width: 100 },
        { field: 'makecycle', title: '加工时间', width: 100 },
        { field: 'transfercycle', title: '转运时间', width: 100 },
        { field: 'shipcycle', title: '转工周期', width: 100 },
        { field: 'chargingqty', title: '装炉/槽量', width: 100 },
        {
          field: 'stepresourcelist', title: '加工设备', width: 300,
          formatter: function (value, row, index) {
            var val = value === null ? '暂无设备' : value;
            return '<span onclick="page.openResourceMaintDialog(\'' + row.stepinfoid + '\')">' + val + '</span>';
          },
          styler: function () {
            return 'color:blue;cursor: pointer;text-decoration: underline;';
          }
        },
        {
          field: 'stepcheckpoint', title: '检测项', width: 120,
          formatter: function (value, row, index) {
            return '<span onclick="page.openStepCheckPointDialog(\'' + row.stepinfoid + '\')">查看检测项</span>';
          },
          styler: function () {
            return 'color:blue;cursor: pointer;text-decoration: underline;';
          }
        },
        {
          field: 'steptools', title: '工装工具', width: 120,
          formatter: function (value, row, index) {
            return '<span onclick="page.openStepToolsDialog(\'' + row.stepinfoid + '\')">查看工装工具</span>';
          },
          styler: function () {
            return 'color:blue;cursor: pointer;text-decoration: underline;';
          }
        },
        {
          field: 'aux', title: '主辅材', width: 120,
          formatter: function (value, row, index) {
            return '<span onclick="page.openStepAuxDialog(\'' + row.stepinfoid + '\')">查看主辅材</span>';
          },
          styler: function () {
            return 'color:blue;cursor: pointer;text-decoration: underline;';
          }
        },
        { field: 'specialcoursespecreportno', title: '特殊过程确认编号', width: 160 }
      ]],
      onCheck: function (rowIndex, rowData) {
        $('#txtPreparecycle').textbox('setValue', rowData.preparecycle);
        $('#txtMakecycle').textbox('setValue', rowData.makecycle);
        $('#txtTransfercycle').textbox('setValue', rowData.transfercycle);
        $('#txtShipcycle').textbox('setValue', rowData.shipcycle);
        $('#txtChargingqty').textbox('setValue', rowData.chargingqty);
        $('#txtStepinfoid').textbox('setValue', rowData.stepinfoid);
        $('#selWorkCenter').combobox('setValue', rowData.workcenterid);
        $('#selTeam').combobox('setValue', rowData.teamid);
      }
    });

    // 件号组件
    $("#productContent").productCombo({
      param: { productName: pname, productID: pid },
      search: function () {
        // page.clearPage();
        $("#workflowContent").workflowCombo("init"); //同时恢复初始化工艺下拉组件
      },
      cancel: function () { //件号取消点击事件
        clearEasyuiDataGrid("tbSpec");
        page.clearPage();
        $("#workflowContent").workflowCombo("init"); //同时恢复初始化工艺下拉组件
      },
      // 件号下拉选择事件
      selected: function (val, text) {
        $("#workflowContent").workflowCombo("init"); //同时恢复初始化工艺下拉组件
        $("#workflowContent").workflowCombo("setCombo", { productName: text }); //联动工艺下拉
        $("#workflowContent").workflowCombo("setValue", wid);
        page.clearPage();
      }
    });

    // 工艺路线组件
    $("#workflowContent").workflowCombo({
      cancel: function () {//工艺取消点击事件
        clearEasyuiDataGrid("tbSpec");
        page.clearPage();
      },
      // 工艺下拉选择事件
      selected: function (val, text) {
        page.clearPage();
        page.search(val);
      }
    });

    // 添加按钮事件
    $("#btnAdd").on("click", function () {
      var stepinfoid = $('#txtStepinfoid').textbox('getValue');
      if (!stepinfoid) {
        displayMessage("请先选择工步", false);
        return;
      }
      //var reg = /^(?!0(\.0+)?$)\d+(\.\d+)?$/;
      var reg = /^\d*\.?\d*$/;
      var preparecycle = $('#txtPreparecycle').textbox('getValue').replace(/^\s+|\s+$/g, "");
      var makecycle = $('#txtMakecycle').textbox('getValue').replace(/^\s+|\s+$/g, "");
      var transfercycle = $('#txtTransfercycle').textbox('getValue').replace(/^\s+|\s+$/g, "");
      var shipcycle = $('#txtShipcycle').textbox('getValue').replace(/^\s+|\s+$/g, "");
      var chargingqty = $('#txtChargingqty').textbox('getValue').replace(/^\s+|\s+$/g, "");
      var workcenterid = $('#selWorkCenter').combobox('getValue'); //工区
      var teamid = $('#selTeam').combobox('getValue'); //班组
      if (preparecycle && !reg.test(preparecycle)) {
        displayMessage("【准备时间】必须是数字", false);
        return;
      }

      if (makecycle && !reg.test(makecycle)) {
        displayMessage("【加工时间】必须是数字", false);
        return;
      }

      if (transfercycle && !reg.test(transfercycle)) {
        displayMessage("【转运时间】必须是数字", false);
        return;
      }

      if (shipcycle && !reg.test(shipcycle)) {
        displayMessage("【转工周期】必须是数字", false);
        return;
      }

      if (chargingqty && !reg.test(chargingqty)) {
        displayMessage("【装炉/槽量】必须是数字", false);
        return;
      }

      var data = {
        action: "updateStepInfo",
        stepinfoid: stepinfoid,
        preparecycle: preparecycle,
        makecycle: makecycle,
        transfercycle: transfercycle,
        shipcycle: shipcycle,
        chargingqty: chargingqty,
        workcenterid: workcenterid,
        teamid: teamid
      };
      page.updateStepInfo(data);
    });

    // 保存工艺温度
    $("#btnTempSave").on("click", function () {
      var rows = $("#tbSpec").datagrid('getData').rows;
      if (rows.length === 0) {
        displayMessage("请先选择工艺", false);
        return;
      }
      var reg = /^\d*\.?\d*$/;
      var temperature = $("#txtTemperature").textbox('getValue');
      if (!temperature) {
        displayMessage("温度不能为空", false);
        return;
      }
      if (!reg.test(temperature)) {
        displayMessage("温度不是有效数字", false);
        return;
      }
      $.postAjax({
        url: page.mainUrl,
        data: {
          action: "updateWorkflowTemp",
          workflowid: page.workflowid,
          image: temperature
        },
        ajaxSuccess: function (res) {
          if (res.total > 0) {
            displayMessage("温度保存成功", true);
          } else {
            displayMessage("温度保存失败", false);
          }
        }
      });
    });

    // 清除事件
    $('#btnReset').on("click", function () {
      $('#txtPreparecycle').textbox('setValue', '');
      $('#txtMakecycle').textbox('setValue', '');
      $('#txtTransfercycle').textbox('setValue', '');
      $('#txtShipcycle').textbox('setValue', '');
      $('#txtChargingqty').textbox('setValue', '');
      $('#selWorkCenter').combobox('clear');
      $('#selTeam').combobox('clear');
      $("#selTeam").combo("panel").empty();
    });

    //批量更新工区班组 add by zhangrj 20241126
    $('#btnBatchWCUpdate').on('click', function () {
      var workcenterid = $('#selWorkCenter').combobox('getValue'); //工区
      var teamid = $('#selTeam').combobox('getValue'); //班组
      var specRows = $("#tbSpec").datagrid('getChecked');
      if (specRows.length === 0) {
        displayMessage("请先选择工序", false);
        return;
      }
      var formData = {
        action: "batchUpdateStepInfo",
        workflowstepid: specRows[0]["workflowstepid"],
        workcenterid: workcenterid,
        teamid: teamid
      };
      $.postAjax({
        url: page.mainUrl,
        data: formData,
        ajaxSuccess: function (res) {
          if (res.total > 0) {
            displayMessage("添加成功", true);
            page.clearPage();
            var spec = $("#tbSpec").datagrid("getChecked");
            if (spec.length > 0) {
              page.getStepInfoData(spec[0]["workflowstepid"]);
            }
          }
        }
      });
    });

    // 工步设备维护--弹窗关闭事件
    $("#resourceDialog").dialog({
      onClose: function () {
        clearEasyuiDataGrid("tbStepResources");
        clearEasyuiDataGrid("tbResourceList");
        $('#txtResourceName').textbox('setValue', '');
        $('#txtResourceDesc').textbox('setValue', '');
      }
    });

    // 工步检测项--关闭弹窗
    $("#specCheckPointDialog").dialog({
      onClose: function () {
        clearEasyuiDataGrid("tbSpecCheckPoint");
      }
    });

    // 工步工装工具--关闭弹窗
    $("#specToolsDialog").dialog({
      onClose: function () {
        clearEasyuiDataGrid("tbSpecTools");
      }
    });

    // 移除设备点击事件
    $("#removeResource").on("click", function () {
      var selection = $("#tbStepResources").datagrid('getChecked');
      if (selection.length === 0) {
        displayMessage("请在左侧区域勾选要移除的设备", false);
        return;
      }
      page.removeStepResources(JSON.stringify(selection));
    });

    // 添加设备点击事件
    $("#addResource").on("click", function () {
      var selection = $("#tbResourceList").datagrid('getChecked');
      var resources = $("#tbStepResources").datagrid('getRows');// 已经绑定的设备
      if (selection.length === 0) {
        displayMessage("请在左侧区域勾选要移除的设备", false);
        return;
      }

      var flag = false;
      var msg = "";
      selection.forEach(function (item) {
        if (resources.some(function (m) { return m.resourceid === item.resourceid; })) {
          flag = true;
          msg += "设备编号:【" + item.resourcename + "】已存在;"
        }
      });

      if (flag) { return displayMessage(msg, false); }

      var stepinfoid = $("#txtStepinfoid").textbox('getValue');
      selection.forEach(function (item) {
        resources.push({
          stepinfoid: stepinfoid,
          resourceid: item.resourceid,
          resourcename: item.resourcename,
          resourcedesc: item.resourcedesc
        })
      });

      var postData = [];
      selection.forEach(function (item) {
        postData.push({
          stepinfoid: stepinfoid,
          resourceid: item.resourceid,
          resourcename: item.resourcename,
          resourcedesc: item.resourcedesc
        })
      });

      $("#tbStepResources").datagrid('loadData', { rows: resources });// 立即更新左侧数据
      page.addStepResources(JSON.stringify(postData));// 更新数据库

    });

    // 查询分厂设备
    $("#btnResourceSearch").on("click", function () {
      var data = {
        action: "getFactoryResources",
        resourcename: $('#txtResourceName').textbox('getValue'),
        resourcedesc: $('#txtResourceDesc').textbox('getValue'),
      }
      page.getFactoryResources(data);
    });

    // 已添加设备
    $("#tbStepResources").datagrid({
      onClickCell: function (index, field, value) {
        // 编辑单元格
        if (page.endEditing('tbStepResources')) {
          $('#tbStepResources').datagrid('editCell', { index: index, field: field });
          page.editIndex = index;
        }
      },
      onEndEdit: function (index, row, changes) {
        var reg = /^\d*\.?\d*$/;
        var chargingqty = row.chargingqty;
        if (!reg.test(chargingqty)) {
          displayMessage("【装炉/装槽量】必须是数字", false);
          row.chargingqty = '';
          $('#tbStepResources').datagrid('updateRow', { index: index, row: row });
          return;
        }
      },
      columns: [[
        { field: 'ck', title: '选择', checkbox: true },
        { field: 'stepinfoid', title: 'stepinfoid', hidden: true },
        { field: 'resourceid', title: 'resourceid', hidden: true },
        { field: 'resourcename', title: '设备编号', width: 100 },
        { field: 'resourcedesc', title: '设备名称', width: 160 },
        { field: 'productname', title: '零件号', width: 80 },
        { field: 'chargingqty', title: '装炉/装槽量', width: 100, editor: 'textbox' }
      ]]
    });

    // 保存装炉槽量
    $('#saveResourceBtn').on("click", function () {
      var selection = $("#tbStepResources").datagrid('getChecked');
      if (selection.length === 0) {
        displayMessage("请勾选要保存的行", false);
        return;
      }

      var filterData = selection.filter(function (item) {
        return item.chargingqty
      });

      if (filterData.length === 0) {
        displayMessage("所选数据中【装炉/装槽量】都没有值", false);
        return;
      }

      filterData.forEach(function (item) {
        item.productname = $("#productContent").productCombo('getText').split(':')[0];
      });

      $.postAjax({
        url: page.mainUrl,
        data: { action: "saveChargingQty", postData: JSON.stringify(filterData) },
        ajaxSuccess: function (res) {
          if (res.data === true) {
            displayMessage("保存成功", true);
          } else {
            displayMessage("保存失败", false);
          }
        }
      });
    });

    // 设备列表
    $("#tbResourceList").datagrid({
      columns: [[
        { field: 'ck', title: '选择', checkbox: true },
        { field: 'resourceid', title: 'resourceid', hidden: true },
        { field: 'resourcename', title: '设备编号', width: 100 },
        { field: 'resourcedesc', title: '设备名称', width: 160 }
      ]]
    });

    // 工步--检测项
    $("#tbSpecCheckPoint").datagrid({
      columns: [[
        { field: 'ck', title: '选择', checkbox: true },
        { field: 'stepcheckpointid', title: 'stepcheckpointid', hidden: true },
        { field: 'stepinfoid', title: 'stepinfoid', hidden: true },
        { field: 'workflowstepid', title: 'workflowstepid', hidden: true },
        { field: 'workflowid', title: 'workflowid', hidden: true },
        { field: 'stepno', title: '工步号', width: 100 },
        { field: 'stepdesc', title: '工步名称', width: 100 },
        { field: 'steptype', title: '工步类型', width: 100 },
        { field: 'checkno', title: '序号', width: 100 },
        { field: 'name', title: '关重符号', width: 100 },
        { field: 'checkpointnotedis', title: '检测内容描述', width: 100 },
        { field: 'drawingrequiredis', title: '图纸要求', width: 100 },
        { field: 'keycheck', title: '关键过程', width: 100 },
        { field: 'qualitycheck', title: '质保单', width: 100 }
      ]]
    });

    // 工步--工装工具
    $("#tbSpecTools").datagrid({
      columns: [[
        { field: 'ck', title: '选择', checkbox: true },
        { field: 'stepinfoid', title: 'stepinfoid', hidden: true },
        { field: 'stepno', title: '工步号', width: 100 },
        { field: 'stepdesc', title: '工步名称', width: 100 },
        { field: 'steptype', title: '工步类型', width: 100 },
        { field: 'toolname', title: '工具编号', width: 100 },
        { field: 'tooldesc', title: '工具名称', width: 100 },
        { field: 'tooltype', title: '工装类型', width: 100 },
        { field: 'xx', title: '需求数', width: 80 },
        { field: 'xx', title: '可用数', width: 80 },
        { field: 'xx', title: '库存数', width: 80 }
      ]]
    });

    $("#tbStepAuxs").datagrid({
      columns: [[
        { field: 'ck', title: '选择', checkbox: true },
        { field: 'stepinfoid', title: 'stepinfoid', hidden: true },
        { field: 'stepno', title: '工步号', width: 100 },
        { field: 'stepdesc', title: '工步名称', width: 100 },
        { field: 'steptype', title: '工步类型', width: 100 },
        { field: 'toolname', title: '辅材编码', width: 100 },
        { field: 'tooldesc', title: '辅材名称', width: 100 },
        { field: 'tooltype', title: '工装类型', width: 100 },
        { field: 'xx', title: '辅材类型', width: 80 },
        { field: 'xx', title: '台账数量', width: 80 },
        { field: 'xx', title: '有效期', width: 80 }
      ]]
    });

  },
  // 初始化页面
  initData: function () {
    $.postAjax({
      url: page.commonUrl,
      data: { action: "getWorkcenterByFactory" },
      ajaxSuccess: function (res) { //ajax成功后
        //绑定工区
        $("#selWorkCenter").combobox({
          valueField: 'WORKCENTERID',
          textField: 'WORKCENTERNAME',
          panelHeight: 200,
          data: res, //下拉数据
          onSelect: function (record) {
            page.bindTeam(record.WORKCENTERID); //加载班组
          }
        });
      }
    });
  },
  //绑定班组
  bindTeam: function (workcenterId) {
    $.postAjax({
      url: page.commonUrl,
      data: { action: "GetTeam", workCenterId: workcenterId },
      ajaxSuccess: function (res) { //ajax成功后
        if (!res.Result) {
          displayMessage(res.Message, res.Result);
          return;
        }
        //绑定班组
        $("#selTeam").combobox({
          valueField: 'TEAMID',
          textField: 'TEAMNAME',
          panelHeight: 200,
          data: res.DBTable //下拉数据
        });
      }
    });
  },
  // 查询工序信息
  search: function (workflowid) {
    page.workflowid = workflowid;
    $('#txtTemperature').textbox('setValue', '');
    $.postAjax({
      url: page.mainUrl,
      data: { action: "getStepData", workflowid: workflowid },
      ajaxSuccess: function (res) {
        if (res.data.length > 0) {
          $("#tbSpec").datagrid('loadData', { rows: res.data });
          if (res.data[0].image) {
            $('#txtTemperature').textbox('setValue', res.data[0].image);
          }
        }
      }
    });
  },
  // 更新工步信息
  updateStepInfo: function (data) {
    $.postAjax({
      url: page.mainUrl,
      data: data,
      ajaxSuccess: function (res) {
        if (res.total > 0) {
          displayMessage("添加成功", true);
          page.clearPage();
          var spec = $("#tbSpec").datagrid("getChecked");
          if (spec.length > 0) {
            page.getStepInfoData(spec[0]["workflowstepid"]);
          }
        }
      }
    });
  },
  // 查询工步信息
  getStepInfoData: function (workflowstepid) {
    $.postAjax({
      url: page.mainUrl,
      data: { action: "getStepInfoData", workflowstepid: workflowstepid },
      ajaxSuccess: function (res) {
        if (res.data.length > 0) {
          $("#tbSteps").datagrid('loadData', { rows: res.data });
        } else {
          $("#tbSteps").datagrid('loadData', { rows: [] });
          displayMessage("没有查询到工步信息", false);
        }
      }
    });
  },
  // 查询工步已绑定设备信息
  getStepResources: function (stepinfoid) {
    var productname = $("#productContent").productCombo('getText');
    if (productname && productname.indexOf(':') > -1) {
      productname = productname.split(':')[0];
    } else {
      return;
    }
    $.postAjax({
      url: page.mainUrl,
      data: { action: "getStepResources", stepinfoid: stepinfoid, productname: productname },
      ajaxSuccess: function (res) {
        $("#tbStepResources").datagrid('loadData', { rows: res.data });
      }
    });
  },
  // 工步添加设备
  addStepResources: function (resources) {
    $.postAjax({
      url: page.mainUrl,
      data: { action: "addStepResources", postData: resources },
      ajaxSuccess: function (res) {
        if (res.data === true) {
          displayMessage("设备添加成功", true);
        } else {
          displayMessage("设备添加成功", false);
        }
      }
    });
  },
  // 移除工步设备
  removeStepResources: function (resources) {
    $.postAjax({
      url: page.mainUrl,
      data: { action: "removeStepResources", postData: resources },
      ajaxSuccess: function (res) {
        if (res.data === true) {
          displayMessage("设备移除成功", true);
          var selection = $("#tbStepResources").datagrid('getChecked');
          var alldata = $("#tbStepResources").datagrid('getRows');
          var filter = alldata.filter(function (item) {
            return !selection.some(function (otherItem) {
              return JSON.stringify(item) === JSON.stringify(otherItem)
            })
          });
          $("#tbStepResources").datagrid('loadData', { rows: filter });
        } else {
          displayMessage("设备移除失败", false);
        }
      }
    });
  },
  // 查询分厂设备
  getFactoryResources: function (data) {
    $.postAjax({
      url: page.mainUrl,
      data: data,
      ajaxSuccess: function (res) {
        if (res.data.length === 0) {
          displayMessage("没有查询到数据", false);
          $("#tbResourceList").datagrid('loadData', { rows: [] });
          return;
        } else {
          $("#tbResourceList").datagrid('loadData', { rows: res.data });
        }
      }
    });
  },
  // 工步--检测项
  getStepCheckPoints: function (stepinfoid) {
    $.postAjax({
      url: page.mainUrl,
      data: { action: 'getStepCheckPoints', stepinfoid: stepinfoid },
      ajaxSuccess: function (res) {
        $("#tbSpecCheckPoint").datagrid('loadData', { rows: res.data });
      }
    });
  },
  // 工步--工装工具
  getStepTools: function (stepinfoid) {
    $.postAjax({
      url: page.mainUrl,
      data: { action: 'getStepTools', stepinfoid: stepinfoid },
      ajaxSuccess: function (res) {
        $("#tbSpecTools").datagrid('loadData', { rows: res.data });
      }
    });
  },
  // 工步--主辅材
  getStepAuxs: function (stepinfoid) {
    $.postAjax({
      url: page.mainUrl,
      data: { action: 'getStepAuxs', stepinfoid: stepinfoid },
      ajaxSuccess: function (res) {
        $("#tbStepAuxs").datagrid('loadData', { rows: res.data });
      }
    });
  },
  // 打开设备维护弹窗
  openResourceMaintDialog: function (stepinfoid) {
    $('#resourceDialog').window('open');
    page.getStepResources(stepinfoid)
  },
  // 打开工步检测项弹窗
  openStepCheckPointDialog: function (stepinfoid) {
    $('#specCheckPointDialog').window('open');
    page.getStepCheckPoints(stepinfoid)
  },
  // 打开工步工装工具弹窗
  openStepToolsDialog: function (stepinfoid) {
    $('#specToolsDialog').window('open');
    page.getStepTools(stepinfoid)
  },
  // 打开工步主辅材弹窗
  openStepAuxDialog: function (stepinfoid) {
    $('#specAuxDialog').window('open');
    page.getStepAuxs(stepinfoid)
  },
  //清空页面
  clearPage: function () {
    clearEasyuiDataGrid("tbSteps");
    $('#txtPreparecycle').textbox('setValue', '');
    $('#txtMakecycle').textbox('setValue', '');
    $('#txtTransfercycle').textbox('setValue', '');
    $('#txtShipcycle').textbox('setValue', '');
    $('#txtChargingqty').textbox('setValue', '');
    $('#selWorkCenter').combobox('clear');
    $('#selTeam').combobox('clear');
    $("#selTeam").combo("panel").empty();
    $('#txtStepinfoid').textbox('setValue', '');
  },
};
page.init();